package com.bx.implatform.growUp.result;

import com.bx.implatform.enums.ResultCode;

public final class GrowUpBaseResultUtils {

    private GrowUpBaseResultUtils() {
    }

    public static <T> GrowUpBaseResult<T> success() {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getMsg());
        return result;
    }

    public static <T> GrowUpBaseResult<T> success(T data) {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getMsg());
        result.setResult(data);
        return result;
    }

    public static <T> GrowUpBaseResult<T> success(T data, String messsage) {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(messsage);
        result.setResult(data);
        return result;
    }

    // public static <T> GrowUpBaseResult<T> success(String messsage) {
    //     GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
    //     result.setCode(ResultCode.SUCCESS.getCode());
    //     result.setMessage(messsage);
    //     return result;
    // }

    public static <T> GrowUpBaseResult<T> error(Integer code, String messsage, String details) {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(code);
        result.setMessage(messsage);
        result.setDetails(details);
        return result;
    }


    public static <T> GrowUpBaseResult<T> error(ResultCode resultCode, String messsage, String details) {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(resultCode.getCode());
        result.setMessage(messsage);
        result.setDetails(details);
        return result;
    }

    public static <T> GrowUpBaseResult<T> error(ResultCode resultCode, String details) {
        GrowUpBaseResult<T> result = new GrowUpBaseResult<>();
        result.setCode(resultCode.getCode());
        result.setMessage(resultCode.getMsg());
        result.setDetails(details);
        return result;
    }


}
